package com.blueskykong.singleton;

/**
 * 懒汉式
 * 内部静态类
 *
 * @author keets
 * @date 2017/11/5
 */
public class InnerStatic {

    /**
     * 利用了classloader的机制来保证初始化instance时只有一个线程，所以也是线程安全的，同时没有性能损耗
     **/
    private static class LazyHolder {
        private static final InnerStatic intance = new InnerStatic();
    }

    private InnerStatic() {
    }

    public static synchronized InnerStatic getInstance() {
        return LazyHolder.intance;
    }


}
